<?php

namespace app\admin\controller\yeemanage;

use app\common\controller\Backend;
use Yeepay\Yop\Sdk\V1\YopConfig;
use Yeepay\Yop\Sdk\V1\YopRequest;
use Yeepay\Yop\Sdk\V1\YopRsaClient;
use sandpay\HmPayClient;
/**
 * 
 *
 * @icon fa fa-circle-o
 */
class Yee extends Backend
{

    /**
     * Yee模型对象
     * @var \app\admin\model\yeemanage\Yee
     */
    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new \app\admin\model\yeemanage\Yee;
        $this->view->assign("businessroleList", $this->model->getBusinessroleList());
        $this->view->assign("signtypeList", $this->model->getSigntypeList());
        $this->view->assign("legallicencetypeList", $this->model->getLegallicencetypeList());
        $this->view->assign("settlementdirectionList", $this->model->getSettlementdirectionList());
        $this->view->assign("bankaccounttypeList", $this->model->getBankaccounttypeList());
        $this->view->assign("applicationstatusList", $this->model->getApplicationstatusList());
    }



    /**
     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
     */

     /**
     * 商户资料提交
     */
    public function submitdata($ids)
    {
    	$row = $this->model->get($ids);
    	
    	 /*商户私钥*/
        $private_key ="MIIEugIBADANBgkqhkiG9w0BAQEFAASCBKQwggSgAgEAAoIBAQCQMqL/T97RhAophQNRzBwE+vU+59PzfkEzyLZwMaQTduHvdTl4fg6KZ6ATFUgECI2JLpZq3cyjVYSlM9H20bRpZSaoYmsYyNibpf2lg+bMg9G+bS6elHvFn0ZJ+aU40wyWqPjtdLB9JYLDbLVsb6SzHegWovWeWD7vUqCbPhDK24V///baX2zV4609kfa1iBGbynF/0nggHw3leeUW9F8E8twSEF15ObE8ShywOMvi578kv9PUNmSiq8gfc/t8dWVOzi4mbDje49MhxMbuopGv1kcvHBrThTeqQ2plhQSs63AbwLpe4WsZbcNvG9zpjuci8bK1+Zb/3DnkmT4zEu6FAgMBAAECggEAHsQfEPhaoztX67nslmRFSi69atmN2HMEuGbHvjJpPpnr5OqPA41pztADUG8G+Y1VnYJqJ40BX4wcjB79Wnst0hr53414KkaYKMWG0+zLrrElbErhWoZ1zhmIprn0LaaiFfchfZCbI2iAeO/V2bgMXQcxgLruSwWrD+cCS303mgBgW7tWsqlfplLvtWqJBWyA4Y8ObV/RUuLjr38Q8nCGZ81ep+De0euDkV4JQ/tg7uQEvEAOwpB6EEBwYt8GZVwcq8SWfP1cOw0Q7hkvn+rHvnXa2MHg8pdQHOfigvHr4Z5udkSiM885Pbjyh6H+UldtKFx2pW9EoD4t37CMwjeJtQKBgQDMWc00sfln9lRUBarV0D7fL6Z8/kueyBaTXFrzauHGwqK9KvB9ADmqFuBxZij8fJBkQyQtgNgbutTqgo0BJgTB2Q5lH097SBUdrTUrJdo3+rKY4/fbQBU7zF9oQ2p+dyFHmW/zjjWALnQYchd1lsZGkrSg2qPto/PRttkES/jrywKBgQC0pLrjcQ+6XZAUie+wSML+f/zGvxw1821Tn8poe0FIaX7/vPhRo028eF+R4Kav/yiVxeTAzk1D5OtN0Q3XO/nIY6f68WbdjBeFFSyovpPi1GX8kSys5wIo79nNnF/cEIJMTnvmyn51RaH8jtSVhshqqzHdesezXTYV3lwg4Urk7wKBgFqKS0ZWuIdcd76GiEuVqdWfOifVT9H5Gy+NUurY51H2OL6RwN3RdLssyaLUvcIoup0BtozGsnmOzPlegHUK0D7HGf6p4cBgjqKIdK86ZTY6SFk/YDjvarkE8xyyCgQgaklb7WM/FetGKcAPBN/fvtfT9l3yoYEQDF5Vok+qDY8DAn80N2nOVOA2/tSnGzgtvNqgtl5bFOMStUrk4Uug5//27ofHZNhiwNG3qRP3FvkX5qnUoV9+XCP5fDKIS+W0UaHiSuxDnYQehmBGF9jQ7kXRS5Qvbcd8M0psiuhqhsku05bWd9lY3S+wtnAckSziDBPiwZmoa9VOA6Oerqfy2SzNAoGAETFFK7YKO6+fGNJv5M5KJuZsOGkqgmfkJhAOnC2wLPDMMFDXnWG+oPcI6bosyvM+I8FDqwE3VcbmFlEJPnC4hQvwK3JjAju6FGhDgoB98rihcaUlsJfoTvrSmkLAmQOH8DW+a0UVbcCMp7TtWgpC8UMT0adAb/4ngQhjYuED4pI=";

        $request = new YopRequest("app_10088909942", $private_key);
        
        $requestNo = 'YBRWQQH'.time();
        if($row->requestNo)$requestNo =$row->requestNo;
        
        $merchantSubjectInfo = array(
                'licenceUrl'   => $row->licenceUrlimage ?? '',
                'signName'     => $row->signName ?? '',
                'signType'     => $row->signType ?? '',
                'licenceNo'    => $row->licenceNo ?? '',
                'shortName'    => $row->shortName ?? '',
                'openAccountLicenceUrl'    => $row->openAccountLicenceUrlimage ?? '',
                'handLicenceUrl'    => $row->handLicenceUrlimage ?? '',
            );     
        $merchantSubjectInfo = json_encode($merchantSubjectInfo);
        $merchantCorporationInfo = array(
                'legalName'   => $row->legalName ?? '',
                'legalLicenceType'     => $row->legalLicenceType ?? '',
                'legalLicenceNo'     => $row->legalLicenceNo ?? '',
                'legalLicenceFrontUrl'    => $row->legalLicenceFrontUrlimage ?? '',
                'legalLicenceBackUrl'    => $row->legalLicenceBackUrlimage ?? '',
            );     
        $merchantCorporationInfo = json_encode($merchantCorporationInfo);
         $merchantContactInfo = array(
                'contactName'   => $row->contactName ?? '',
                'contactMobile'     => $row->contactMobile ?? '',
                'contactEmail'     => $row->contactEmail ?? '',
                'contactLicenceNo'    => $row->contactLicenceNo ?? '',
            );     
        $merchantContactInfo = json_encode($merchantContactInfo);
        
        $YeeArea = \app\admin\model\yeemanage\YeeArea::where('provice_code',$row->province)->where('city_code',$row->city)->where('district_code',$row->district)->find();
  
        $businessAddressInfo = array(
                'province'   => $row->province ?? '',
                'city'     => $row->city ?? '',
                'district'     => $row->district ?? '',
                'address'    => $row->address ?? '',
            );     
        $businessAddressInfo = json_encode($businessAddressInfo);
        
        $settlementAccountInfo = array(
                'settlementDirection'   => $row->settlementDirection ?? '',
                'bankCode'     => $row->bankCode ?? '',
                'bankAccountType'     => $row->bankAccountType ?? '',
                'bankCardNo'    => $row->bankCardNo ?? '',
            );     
        $settlementAccountInfo = json_encode($settlementAccountInfo);
        $productInfo = '[{"productCode":"MINI_PROGRAM_WECHAT_ONLINE","rateType":"SINGLE_PERCENT","percentRate":"0.63"},{"productCode":"MERCHANT_SCAN_ALIPAY_OFFLINE","rateType":"SINGLE_PERCENT","percentRate":"0.23"},{"productCode":"MERCHANT_SCAN_WECHAT_OFFLINE","rateType":"SINGLE_PERCENT","percentRate":"0.23"},{"productCode":"USER_SCAN_WECHAT_OFFLINE","rateType":"SINGLE_PERCENT","percentRate":"0.23"},{"productCode":"USER_SCAN_ALIPAY_OFFLINE","rateType":"SINGLE_PERCENT","percentRate":"0.23"},{"productCode":"MERCHANT_SCAN_UNIONPAY_CREDIT","rateType":"SINGLE_PERCENT","percentRate":"0.51"},{"productCode":"D1","rateType":"SINGLE_FIXED","fixedRate":"0"},{"productCode":"MINI_PROGRAM_WECHAT_OFFLINE","rateType":"SINGLE_PERCENT","percentRate":"0.23","undertaker":"PLATFORM_MERCHANT","paymentMethod":"REAL_TIME"},{"productCode":"MINI_PROGRAM_ALIPAY_OFFLINE","rateType":"SINGLE_PERCENT","percentRate":"0.23","undertaker":"PLATFORM_MERCHANT","paymentMethod":"REAL_TIME"},{"productCode":"MERCHANT_SCAN_UNIONPAY_DEBIT","rateType":"SINGLE_PERCENT","percentRate":"0.23","undertaker":"PLATFORM_MERCHANT","paymentMethod":"REAL_TIME"},{"productCode":"POS_CREDIT","rateType":"SINGLE_PERCENT","percentRate":"0.51","undertaker":"PLATFORM_MERCHANT","paymentMethod":"REAL_TIME"},{"productCode":"POS_DEBIT","rateType":"PERCENT_MIX_CAP","percentRate":"0.3","fixedRate":"20","undertaker":"PLATFORM_MERCHANT","paymentMethod":"REAL_TIME"}]';
        
        $productQualificationInfo = array(
                'mcc'   => '5541' ?? '',
                'scenePhotoUrl'   => $row->scenePhotoUrlimage ?? '',
                'businessPlacePhotoUrl'     => $row->businessPlacePhotoUrlimage ?? '',
                'internetType'     => ["MOBILE"],
                'terminalType'     => 'WECHANT_APPLET',
                'terminalName'     => $row->wchatName ?? '',
                'terminalTestAccount'     => '手机号授权登录',
                'terminalTestPassword'     => '手机号授权登录',
            );     
        $productQualificationInfo = json_encode($productQualificationInfo);
//      $productQualificationInfo = '{"scenePhotoUrl":"http://staticres.yeepay.com/jcptb-merchant-netinjt05/2023/01/01/merchant-1672506127713-63b06b0d1e4a43956263231fad0adabe-OhUMsUWSuzLUAjCjfzSN.jpg","businessPlacePhotoUrl":"http://staticres.yeepay.com/jcptb-merchant-netinjt05/2023/01/01/merchant-1672506127713-63b06b0d1e4a43956263231fad0adabe-OhUMsUWSuzLUAjCjfzSN.jpg","internetType":["MOBILE"],"terminalType":"WECHANT_APPLET","terminalName":"您的手机端名称/地址","terminalTestAccount":"您的手机端测试账号","terminalTestPassword":"您的手机端测试账号密码"}';
        //加入请求参数
        $request->addParam("requestNo",$requestNo);
        $request->addParam("businessRole",$row->businessRole);
        $request->addParam("parentMerchantNo",'10088970121');
        $request->addParam("merchantSubjectInfo",$merchantSubjectInfo);
        $request->addParam("merchantCorporationInfo",$merchantCorporationInfo);
        $request->addParam("merchantContactInfo",$merchantContactInfo);
        $request->addParam("businessAddressInfo",$businessAddressInfo);
        $request->addParam("settlementAccountInfo",$settlementAccountInfo);
        $request->addParam("productInfo",$productInfo);
        $request->addParam("productQualificationInfo",$productQualificationInfo);
        $request->addParam("notifyUrl",'https://store.leyinshuke.com/api/index/notify');
//      //提交Post请求
        $response = YopRsaClient::post("/rest/v2.0/mer/register/saas/merchant", $request);
           $response = json_decode($response,true);
        if(isset($response['result']['returnCode']) && $response['result']['returnCode'] == 'NIG00000')
			        {
			        	$params['requestNo'] = $requestNo;
			        	$params['applicationStatus'] = $response['result']['applicationStatus'];
			        	$params['applicationNo'] = $response['result']['applicationNo'];
		                 $row->save($params);
			        	$this->success($response['result']['returnMsg']);
			        }
        
        $this->success('提交失败','',$response['result']['returnMsg']);
    }
    
         /**
     * 商户资料变更提交
     */
    public function submitchangedata($ids)
    {
    	$row = $this->model->get($ids);
    	
    	 /*商户私钥*/
        $private_key ="MIIEugIBADANBgkqhkiG9w0BAQEFAASCBKQwggSgAgEAAoIBAQCQMqL/T97RhAophQNRzBwE+vU+59PzfkEzyLZwMaQTduHvdTl4fg6KZ6ATFUgECI2JLpZq3cyjVYSlM9H20bRpZSaoYmsYyNibpf2lg+bMg9G+bS6elHvFn0ZJ+aU40wyWqPjtdLB9JYLDbLVsb6SzHegWovWeWD7vUqCbPhDK24V///baX2zV4609kfa1iBGbynF/0nggHw3leeUW9F8E8twSEF15ObE8ShywOMvi578kv9PUNmSiq8gfc/t8dWVOzi4mbDje49MhxMbuopGv1kcvHBrThTeqQ2plhQSs63AbwLpe4WsZbcNvG9zpjuci8bK1+Zb/3DnkmT4zEu6FAgMBAAECggEAHsQfEPhaoztX67nslmRFSi69atmN2HMEuGbHvjJpPpnr5OqPA41pztADUG8G+Y1VnYJqJ40BX4wcjB79Wnst0hr53414KkaYKMWG0+zLrrElbErhWoZ1zhmIprn0LaaiFfchfZCbI2iAeO/V2bgMXQcxgLruSwWrD+cCS303mgBgW7tWsqlfplLvtWqJBWyA4Y8ObV/RUuLjr38Q8nCGZ81ep+De0euDkV4JQ/tg7uQEvEAOwpB6EEBwYt8GZVwcq8SWfP1cOw0Q7hkvn+rHvnXa2MHg8pdQHOfigvHr4Z5udkSiM885Pbjyh6H+UldtKFx2pW9EoD4t37CMwjeJtQKBgQDMWc00sfln9lRUBarV0D7fL6Z8/kueyBaTXFrzauHGwqK9KvB9ADmqFuBxZij8fJBkQyQtgNgbutTqgo0BJgTB2Q5lH097SBUdrTUrJdo3+rKY4/fbQBU7zF9oQ2p+dyFHmW/zjjWALnQYchd1lsZGkrSg2qPto/PRttkES/jrywKBgQC0pLrjcQ+6XZAUie+wSML+f/zGvxw1821Tn8poe0FIaX7/vPhRo028eF+R4Kav/yiVxeTAzk1D5OtN0Q3XO/nIY6f68WbdjBeFFSyovpPi1GX8kSys5wIo79nNnF/cEIJMTnvmyn51RaH8jtSVhshqqzHdesezXTYV3lwg4Urk7wKBgFqKS0ZWuIdcd76GiEuVqdWfOifVT9H5Gy+NUurY51H2OL6RwN3RdLssyaLUvcIoup0BtozGsnmOzPlegHUK0D7HGf6p4cBgjqKIdK86ZTY6SFk/YDjvarkE8xyyCgQgaklb7WM/FetGKcAPBN/fvtfT9l3yoYEQDF5Vok+qDY8DAn80N2nOVOA2/tSnGzgtvNqgtl5bFOMStUrk4Uug5//27ofHZNhiwNG3qRP3FvkX5qnUoV9+XCP5fDKIS+W0UaHiSuxDnYQehmBGF9jQ7kXRS5Qvbcd8M0psiuhqhsku05bWd9lY3S+wtnAckSziDBPiwZmoa9VOA6Oerqfy2SzNAoGAETFFK7YKO6+fGNJv5M5KJuZsOGkqgmfkJhAOnC2wLPDMMFDXnWG+oPcI6bosyvM+I8FDqwE3VcbmFlEJPnC4hQvwK3JjAju6FGhDgoB98rihcaUlsJfoTvrSmkLAmQOH8DW+a0UVbcCMp7TtWgpC8UMT0adAb/4ngQhjYuED4pI=";

        $request = new YopRequest("app_10088909942", $private_key);
        
        $requestNo = 'YBRWQQH'.time();
//      if($row->requestNo)$requestNo =$row->requestNo;
        
        $merchantSubjectInfo = array(
                'licenceUrl'   => $row->licenceUrlimage ?? '',
                'signName'     => $row->signName ?? '',
                'signType'     => $row->signType ?? '',
                'licenceNo'    => $row->licenceNo ?? '',
                'shortName'    => $row->shortName ?? '',
                'openAccountLicenceUrl'    => $row->openAccountLicenceUrlimage ?? '',
                'handLicenceUrl'    => $row->handLicenceUrlimage ?? '',
            );     
        $merchantSubjectInfo = json_encode($merchantSubjectInfo);
        $merchantCorporationInfo = array(
                'legalName'   => $row->legalName ?? '',
                'legalLicenceType'     => $row->legalLicenceType ?? '',
                'legalLicenceNo'     => $row->legalLicenceNo ?? '',
                'legalLicenceFrontUrl'    => $row->legalLicenceFrontUrlimage ?? '',
                'legalLicenceBackUrl'    => $row->legalLicenceBackUrlimage ?? '',
            );     
        $merchantCorporationInfo = json_encode($merchantCorporationInfo);
         $merchantContactInfo = array(
                'contactName'   => $row->contactName ?? '',
                'contactMobile'     => $row->contactMobile ?? '',
                'contactEmail'     => $row->contactEmail ?? '',
                'contactLicenceNo'    => $row->contactLicenceNo ?? '',
            );     
        $merchantContactInfo = json_encode($merchantContactInfo);
        
        $YeeArea = \app\admin\model\yeemanage\YeeArea::where('provice_code',$row->province)->where('city_code',$row->city)->where('district_code',$row->district)->find();
  
        $businessAddressInfo = array(
                'province'   => $row->province ?? '',
                'city'     => $row->city ?? '',
                'district'     => $row->district ?? '',
                'address'    => $row->address ?? '',
            );     
        $businessAddressInfo = json_encode($businessAddressInfo);
        
        $settlementAccountInfo = array(
                'settlementDirection'   => $row->settlementDirection ?? '',
                'bankCode'     => $row->bankCode ?? '',
                'bankAccountType'     => $row->bankAccountType ?? '',
                'bankCardNo'    => $row->bankCardNo ?? '',
            );     
        $settlementAccountInfo = json_encode($settlementAccountInfo);
        $productInfo = '[{"productCode":"MINI_PROGRAM_WECHAT_OFFLINE","rateType":"SINGLE_PERCENT","percentRate":"0.23","undertaker":"PLATFORM_MERCHANT","paymentMethod":"REAL_TIME"},{"productCode":"MINI_PROGRAM_ALIPAY_OFFLINE","rateType":"SINGLE_PERCENT","percentRate":"0.23","undertaker":"PLATFORM_MERCHANT","paymentMethod":"REAL_TIME"},{"productCode":"MERCHANT_SCAN_UNIONPAY_DEBIT","rateType":"SINGLE_PERCENT","percentRate":"0.23","undertaker":"PLATFORM_MERCHANT","paymentMethod":"REAL_TIME"},{"productCode":"POS_CREDIT","rateType":"SINGLE_PERCENT","percentRate":"0.51","undertaker":"PLATFORM_MERCHANT","paymentMethod":"REAL_TIME"},{"productCode":"POS_DEBIT","rateType":"PERCENT_MIX_CAP","percentRate":"0.3","fixedRate":"20","undertaker":"PLATFORM_MERCHANT","paymentMethod":"REAL_TIME"}]';
        
        $productQualificationInfo = array(
                'mcc'   => '5541' ?? '',
                'scenePhotoUrl'   => $row->scenePhotoUrlimage ?? '',
                'businessPlacePhotoUrl'     => $row->businessPlacePhotoUrlimage ?? '',
                'internetType'     => ["MOBILE"],
                'terminalType'     => 'WECHANT_APPLET',
                'terminalName'     => $row->wchatName ?? '',
                'terminalTestAccount'     => '手机号授权登录',
                'terminalTestPassword'     => '手机号授权登录',
            );     
        $productQualificationInfo = json_encode($productQualificationInfo);
//      $productQualificationInfo = '{"scenePhotoUrl":"http://staticres.yeepay.com/jcptb-merchant-netinjt05/2023/01/01/merchant-1672506127713-63b06b0d1e4a43956263231fad0adabe-OhUMsUWSuzLUAjCjfzSN.jpg","businessPlacePhotoUrl":"http://staticres.yeepay.com/jcptb-merchant-netinjt05/2023/01/01/merchant-1672506127713-63b06b0d1e4a43956263231fad0adabe-OhUMsUWSuzLUAjCjfzSN.jpg","internetType":["MOBILE"],"terminalType":"WECHANT_APPLET","terminalName":"您的手机端名称/地址","terminalTestAccount":"您的手机端测试账号","terminalTestPassword":"您的手机端测试账号密码"}';
        //分账
        $functionService = ["SHARE"];
        $functionServiceQualificationInfo = array(
                'shareScene'   => 'FZ_WL001',
                'shareCertificate'     => '',
            );     
        $functionServiceQualificationInfo = json_encode($functionServiceQualificationInfo);
     
        //加入请求参数
        $request->addParam("requestNo",$requestNo);
        $request->addParam("businessRole",$row->businessRole);
        $request->addParam("parentMerchantNo",'10088970121');
        $request->addParam("merchantNo",$row->merchantNo);
//      $request->addParam("merchantSubjectInfo",$merchantSubjectInfo);
//      $request->addParam("merchantCorporationInfo",$merchantCorporationInfo);
//      $request->addParam("merchantContactInfo",$merchantContactInfo);
//      $request->addParam("businessAddressInfo",$businessAddressInfo);
//      $request->addParam("settlementAccountInfo",$settlementAccountInfo);
        $request->addParam("productInfo",$productInfo);
        $request->addParam("productQualificationInfo",$productQualificationInfo);
        $request->addParam("notifyUrl",'https://store.leyinshuke.com/api/index/notify');
        $request->addParam("functionService",'["SHARE"]');
        $request->addParam("functionServiceQualificationInfo",$functionServiceQualificationInfo);
//      //提交Post请求
        $response = YopRsaClient::post("/rest/v2.0/mer/product/fee/modify", $request);
        $response = json_decode($response,true);
        if(isset($response['result']['returnCode']) && $response['result']['returnCode'] == 'NIG00000')
			        {
			        	$params['requestNo'] = $requestNo;
			        	$params['applicationStatus'] = $response['result']['applicationStatus'];
			        	$params['applicationNo'] = $response['result']['applicationNo'];
		                 $row->save($params);
			        	$this->success($response['result']['returnMsg']);
			        }
        
        $this->success('提交失败','',$response['result']['returnMsg']);
    }
    
             /**
     * 小程序配置
     */
    public function smalldata($ids)
    {
    	$row = $this->model->get($ids);
    	
    	 /*商户私钥*/
        $private_key ="MIIEugIBADANBgkqhkiG9w0BAQEFAASCBKQwggSgAgEAAoIBAQCQMqL/T97RhAophQNRzBwE+vU+59PzfkEzyLZwMaQTduHvdTl4fg6KZ6ATFUgECI2JLpZq3cyjVYSlM9H20bRpZSaoYmsYyNibpf2lg+bMg9G+bS6elHvFn0ZJ+aU40wyWqPjtdLB9JYLDbLVsb6SzHegWovWeWD7vUqCbPhDK24V///baX2zV4609kfa1iBGbynF/0nggHw3leeUW9F8E8twSEF15ObE8ShywOMvi578kv9PUNmSiq8gfc/t8dWVOzi4mbDje49MhxMbuopGv1kcvHBrThTeqQ2plhQSs63AbwLpe4WsZbcNvG9zpjuci8bK1+Zb/3DnkmT4zEu6FAgMBAAECggEAHsQfEPhaoztX67nslmRFSi69atmN2HMEuGbHvjJpPpnr5OqPA41pztADUG8G+Y1VnYJqJ40BX4wcjB79Wnst0hr53414KkaYKMWG0+zLrrElbErhWoZ1zhmIprn0LaaiFfchfZCbI2iAeO/V2bgMXQcxgLruSwWrD+cCS303mgBgW7tWsqlfplLvtWqJBWyA4Y8ObV/RUuLjr38Q8nCGZ81ep+De0euDkV4JQ/tg7uQEvEAOwpB6EEBwYt8GZVwcq8SWfP1cOw0Q7hkvn+rHvnXa2MHg8pdQHOfigvHr4Z5udkSiM885Pbjyh6H+UldtKFx2pW9EoD4t37CMwjeJtQKBgQDMWc00sfln9lRUBarV0D7fL6Z8/kueyBaTXFrzauHGwqK9KvB9ADmqFuBxZij8fJBkQyQtgNgbutTqgo0BJgTB2Q5lH097SBUdrTUrJdo3+rKY4/fbQBU7zF9oQ2p+dyFHmW/zjjWALnQYchd1lsZGkrSg2qPto/PRttkES/jrywKBgQC0pLrjcQ+6XZAUie+wSML+f/zGvxw1821Tn8poe0FIaX7/vPhRo028eF+R4Kav/yiVxeTAzk1D5OtN0Q3XO/nIY6f68WbdjBeFFSyovpPi1GX8kSys5wIo79nNnF/cEIJMTnvmyn51RaH8jtSVhshqqzHdesezXTYV3lwg4Urk7wKBgFqKS0ZWuIdcd76GiEuVqdWfOifVT9H5Gy+NUurY51H2OL6RwN3RdLssyaLUvcIoup0BtozGsnmOzPlegHUK0D7HGf6p4cBgjqKIdK86ZTY6SFk/YDjvarkE8xyyCgQgaklb7WM/FetGKcAPBN/fvtfT9l3yoYEQDF5Vok+qDY8DAn80N2nOVOA2/tSnGzgtvNqgtl5bFOMStUrk4Uug5//27ofHZNhiwNG3qRP3FvkX5qnUoV9+XCP5fDKIS+W0UaHiSuxDnYQehmBGF9jQ7kXRS5Qvbcd8M0psiuhqhsku05bWd9lY3S+wtnAckSziDBPiwZmoa9VOA6Oerqfy2SzNAoGAETFFK7YKO6+fGNJv5M5KJuZsOGkqgmfkJhAOnC2wLPDMMFDXnWG+oPcI6bosyvM+I8FDqwE3VcbmFlEJPnC4hQvwK3JjAju6FGhDgoB98rihcaUlsJfoTvrSmkLAmQOH8DW+a0UVbcCMp7TtWgpC8UMT0adAb/4ngQhjYuED4pI=";

        $request = new YopRequest("app_10088909942", $private_key);
        
        
        $storeinfo = \app\admin\model\Storeset::where('store_no',$row->store_no)->find();
  

        $tradeAuthDirList = '["https://store.leyinshuke.com"]';
        $appIdList[] = array(
                'appId'   => $storeinfo->wx_appid ?? '',
                'appSecret'   => $storeinfo->wx_app_secret ?? '',
                'appIdType'     => 'MINI_PROGRAM',
                'subscribeAppId'     => $storeinfo->wx_appid ?? '',
            );     
        $appIdList = json_encode($appIdList);


        //加入请求参数
        $request->addParam("parentMerchantNo",'10088970121');
        $request->addParam("merchantNo",$row->merchantNo);
        $request->addParam("tradeAuthDirList",$tradeAuthDirList);
        $request->addParam("appIdList",$appIdList);

//      //提交Post请求
        $response = YopRsaClient::post("/rest/v2.0/aggpay/wechat-config/add", $request);
        
        $jsonResp = json_decode($response, JSON_UNESCAPED_UNICODE);
        $params['is_wechat'] = $jsonResp['result']['status'];
		                 $row->save($params);
        $this->success($jsonResp['result']['message']);
    }
}
